# 2024.6
h = int(input())
m = int(input())
s = int(input())
k = input(input())
if s + k > 60:
    m += 1
    s = s - 60
else:
    s += k
if m > 60:
    h += 1
    m = m - 60

print(h,m,s)